package tree;

import java.util.ArrayList;
import java.util.List;

/**
 * 多叉树,节点创建,遍历，添加节点等
 * @author Api
 * @date 2023/9/23 1:02
 */
public class MultiBranchTree {
    static class TreeNode{
        TreeNode parent;
        String value;
        String status;
        List<TreeNode> children;

        public TreeNode(String value){
            this.value = value;
            this.parent = null;
            this.children = new ArrayList<>();
        }
    }
    // 遍历父节点
    public static List<TreeNode> traverseParent(TreeNode node){
        List<TreeNode> parents = new ArrayList<>();
        TreeNode parent = node.parent;
        while(parent != null){
            parents.add(parent);
            parent = parent.parent;
        }
        return parents;
    }


}

